package com.fancy.mobileschool.ui.adapt;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fancy.mobileschool.R;

import com.fancy.mobileschool.entity.YunFile;

import java.util.List;

/**
 *
 * TODO: Replace the implementation with code for your data type.
 */
public class FileRecyclerViewAdapter extends RecyclerView.Adapter<FileRecyclerViewAdapter.ViewHolder> {

    private final List<YunFile> mValues;

    public FileRecyclerViewAdapter(List<YunFile> items) {
        mValues = items;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.fragment_file, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        holder.mItem = mValues.get(position);
        holder.file_item_name.setText(mValues.get(position).file_name);
        holder.file_item_length.setText("大小: " + mValues.get(position).file_length);

    }

    @Override
    public int getItemCount() {
        return mValues.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public final View mView;
        public final TextView file_item_name;
        public final TextView file_item_length;
        public YunFile mItem;

        public ViewHolder(View view) {
            super(view);
            mView = view;
            file_item_name = (TextView) view.findViewById(R.id.file_item_name);
            file_item_length = (TextView) view.findViewById(R.id.file_item_length);
        }
    }
}
